
#ifndef FIBER_ENV_COOPERATIVE_FD_H_
#define FIBER_ENV_COOPERATIVE_FD_H_

#include "./epoll.h"

namespace fasmio { namespace fiber_env {

class CooperativeFD
{
public:
    CooperativeFD();
    ~CooperativeFD();

public:
    int Attach(int fd);
    void Dettach();

    long Write(const void* buff, unsigned long size, const char* state);
    long Read(void* buff, unsigned long size, const char* state);
    long WriteAll(const void* buff, unsigned long size, const char* state);
    long ReadAll(void* buff, unsigned long size, const char* state);

    bool WaitForWritable(const char* state);
    bool WaitForReadable(const char* state);

private:
    int fd_;
    Epoller *epoller_;
};

}}  // namespace fasmio::fiber_env

#endif  // FIBER_ENV_COOPERATIVE_FD_H_

